﻿using System;
using System.Collections.Generic;
using System.Text;

using Gx.Dal.Employee;//数据
using Gx.Model.Entity;//实体
using Gx.Common;//通用类
namespace Gx.Bll.Employee
{
    public class G_StockOutBackGoodsInfoBll
    {

        public bool AddG_StockOutBackGoodsInfo(G_StockOutBackGoodsInfo model)
        {
            using (G_StockOutBackGoodsInfoDal dal = new G_StockOutBackGoodsInfoDal())
            {
                return dal.AddG_StockOutBackGoodsInfo(model);
            }
        }

        public bool DelG_StockOutBackGoodsInfo(int stockOutBackGoodsId)
        {
            using (G_StockOutBackGoodsInfoDal dal = new G_StockOutBackGoodsInfoDal())
            {
                return dal.DelG_StockOutBackGoodsInfo(stockOutBackGoodsId);
            }
        }

        public bool EditG_StockOutBackGoodsInfo(G_StockOutBackGoodsInfo model)
        {
            using (G_StockOutBackGoodsInfoDal dal = new G_StockOutBackGoodsInfoDal())
            {
                return dal.EditG_StockOutBackGoodsInfo(model);
            }
        }


        private List<G_StockOutBackGoodsInfo> GetG_StockOutBackGoodsInfoList(string strWhere)
        {
            using (G_StockOutBackGoodsInfoDal dal = new G_StockOutBackGoodsInfoDal())
            {
                return dal.GetG_StockOutBackGoodsInfoList(strWhere);
            }
        }

        public List<G_StockOutBackGoodsInfo> GetG_StockOutBackGoodsInfoList(
        int pageIndex, int pageSize, out int totalCount)
        {
            using (G_StockOutBackGoodsInfoDal dal = new G_StockOutBackGoodsInfoDal())
            {
                int PageIndex = (pageIndex - 1) * pageSize + 1;
                int PageSize = pageIndex * pageSize;
                StringBuilder strWhere = new StringBuilder();
                return dal.GetG_StockOutBackGoodsInfoList(strWhere.ToString(), PageIndex, PageSize, out totalCount);
            }
        }

        private int GetG_StockOutBackGoodsInfoCount(string strWhere)
        {
            using (G_StockOutBackGoodsInfoDal dal = new G_StockOutBackGoodsInfoDal())
            {
                return dal.GetG_StockOutBackGoodsInfoCount(strWhere);
            }
        }

        public G_StockOutBackGoodsInfo GetG_StockOutBackGoodsInfoModel(int stockOutBackGoodsId)
        {
            using (G_StockOutBackGoodsInfoDal dal = new G_StockOutBackGoodsInfoDal())
            {
                return dal.GetG_StockOutBackGoodsInfoModel(stockOutBackGoodsId);
            }
        }

        public List<G_StockOutBackGoodsInfo> GetG_StockOutBackGoodsInfoDetails(int StockOutBackId)
        {
            StringBuilder strWhere = new StringBuilder();
            strWhere.AppendFormat(" AND StockOutBackId={0}", StockOutBackId);
            List<G_StockOutBackGoodsInfo> list = GetG_StockOutBackGoodsInfoList(strWhere.ToString());
            list.ForEach(x =>
            {
                x.StrGoodsNum = x.GoodsNum.ToStringf2();
            });
            return list;
        }
    }
}
